#include<iostream>
using namespace std;

class Solution {
public:
    int myAtoi(string str) {
        int i = 0;
        int falg = 1;
        int ret = 0;
        if (str.size() == 0)
        {
            return 0;
        }
        while (str[i] == ' ')
        {
            ++i;
            if (str.size() == i)
            {
                return 0;
            }
        }
        if (str[i] == '-')
        {
            falg = -1;
            ++i;
        }
        else if (str[i] == '+')
        {
            ++i;
        }
        while (i < str.size())
        {
            if (str[i] >= '0' && str[i] <= '9')
            {
                if (ret > 214748364 || (ret == 214748364 && str[i] > '7'))
                {
                    return falg == 1 ? 2147483647 : -2147483648;
                }
                ret = ret * 10 + (str[i] - '0');
                ++i;
            }
            else
            {
                break;
            }
        }
        return ret * falg;
    }
};





class Solution {
public:
    string addStrings(string num1, string num2) {
        string res;
        int n1 = num1.size() - 1;
        int n2 = num2.size() - 1;
        int add = 0;
        while (n1 >= 0 || n2 >= 0 || add != 0)
        {
            int x = n1 >= 0 ? num1[n1] - '0' : 0;
            int y = n2 >= 0 ? num2[n2] - '0' : 0;
            int r = x + y + add;
            res += (r % 10 + '0');
            add = r / 10;
            --n1;
            --n2;
        }
        reverse(res.begin(), res.end());
        return res;
    }
};

int main()
{
    return 0;
}